#coding=utf-8
import serial
import os
import time
import time
import ConfigParser

Conf = ConfigParser.ConfigParser()

with open(r"E:\eclipse\huawei_rader\src\common\configuration.txt") as f:
    Conf.readfp(f)
    Mtktool_Log_Path = Conf.get("Mtktool_Log_Path", "key")
    Log_Path = Conf.get("LogPath", "key")

def save_log(StartTime,EndTime,Name):                                               #StartTime/EndTime传递的格式必须是151024_11:04:51格式
    with open(Mtktool_Log_Path) as f:                                               #打开Mtktool工具抓Log保存地址
        Data = f.readlines()                                                        #读取Log信息到列表中
        for eachline in Data:                                                       #对列表中每个元素进行操作
            if eachline[1:16] >= StartTime and eachline[1:16] <= EndTime:           #对每行Log信息去时间关键字判断，符合要求写入每个脚本对应的Log文档
                with open(Log_Path+Name+'.txt',"a+") as f:                          #Log_Path是从配置文件读取，Name是脚本名
                    f.write(eachline)
                    

#save_log("160318_13:46:46", "160318_13:47:26", "\\ximayalay_zixun\\serial_log3")

